<?php
/**
 * Created by PhpStorm.
 * User: Dale
 * Date: 2017/7/4
 * Time: 10:04
 */

$dsn = 'mysql:dbname=MyBlog;host=192.168.76.11';
$user = 'root';
$password = '123456';
try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$time = date('Y-m-d H:i:s',time());

$title = $_POST['title'];

$contents = $_POST['contents'];

$classid = $_POST['classid'];

$abstract = $_POST['abstract'];

$sql="insert into tb_article(Title,PublishTime,Abstract,Contents,ClassID)
    values('".$title."','".$time."','".$abstract."','".$contents."','".$classid."')";

$statement = $dbh->exec($sql);
if($statement > 0 ){

}
else{
        die('SQL出错'.$dbh->errorInfo()[2]);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Blog Design</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<meta http-equiv="refresh" content="3;url=index.php"/>
<body>
<div id="header">
    <ul id="menu">
        <li><a href="index.php"><img src="images/but1.gif" alt="" width="64" height="42" /></a></li>
        <li><a href="index.php"><img src="images/but2.gif" alt="" width="108" height="42" /></a></li>
        <li><a href="index.php"><img src="images/but3.gif" alt="" width="93" height="42" /></a></li>
    </ul>
</div>

<div align="center">
    <p>发表成功！</p>
    1 秒后将跳转至<a href="index.php">首页</a>
</div>


<div id="footer">
    <p>Copyright &copy;. All rights reserved.</p>
</div>

</body>
</html>

